/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('mns-open', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model EventMatchRule {
  matchState?: boolean(name='MatchState', example='true'),
  name?: string(name='Name'),
  prefix?: string(name='Prefix'),
  suffix?: string(name='Suffix'),
}

model AuthorizeEndpointAclRequest {
  aclStrategy?: string(name='AclStrategy', description='The ACL policy. Valid values:

*   **allow**: indicates that this operation is included in the Cidr whitelist. (Only the allow is supported.)

This parameter is required.', example='allow'),
  cidrList?: [ string ](name='CidrList', description='The list of CIDR block.

This parameter is required.'),
  endpointType?: string(name='EndpointType', description='The type of the endpoint. Valid values:

*   **public**: indicates public endpoint. (Only the public endpoint is supported.)

This parameter is required.', example='public'),
}

model AuthorizeEndpointAclShrinkRequest {
  aclStrategy?: string(name='AclStrategy', description='The ACL policy. Valid values:

*   **allow**: indicates that this operation is included in the Cidr whitelist. (Only the allow is supported.)

This parameter is required.', example='allow'),
  cidrListShrink?: string(name='CidrList', description='The list of CIDR block.

This parameter is required.'),
  endpointType?: string(name='EndpointType', description='The type of the endpoint. Valid values:

*   **public**: indicates public endpoint. (Only the public endpoint is supported.)

This parameter is required.', example='public'),
}

model AuthorizeEndpointAclResponseBody = {
  code?: long(name='Code', description='The HTTP status code.', example='200'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model AuthorizeEndpointAclResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AuthorizeEndpointAclResponseBody(name='body'),
}

/**
 * @summary You can call this operation to add one or more rules of access control lists (ACLs) for the endpoint of a type.
 *
 * @param tmpReq AuthorizeEndpointAclRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AuthorizeEndpointAclResponse
 */
async function authorizeEndpointAclWithOptions(tmpReq: AuthorizeEndpointAclRequest, runtime: Util.RuntimeOptions): AuthorizeEndpointAclResponse {
  Util.validateModel(tmpReq);
  var request = new AuthorizeEndpointAclShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.cidrList)) {
    request.cidrListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.cidrList, 'CidrList', 'simple');
  }
  var query = {};
  if (!Util.isUnset(request.aclStrategy)) {
    query['AclStrategy'] = request.aclStrategy;
  }
  if (!Util.isUnset(request.cidrListShrink)) {
    query['CidrList'] = request.cidrListShrink;
  }
  if (!Util.isUnset(request.endpointType)) {
    query['EndpointType'] = request.endpointType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AuthorizeEndpointAcl',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary You can call this operation to add one or more rules of access control lists (ACLs) for the endpoint of a type.
 *
 * @param request AuthorizeEndpointAclRequest
 * @return AuthorizeEndpointAclResponse
 */
async function authorizeEndpointAcl(request: AuthorizeEndpointAclRequest): AuthorizeEndpointAclResponse {
  var runtime = new Util.RuntimeOptions{};
  return authorizeEndpointAclWithOptions(request, runtime);
}

model CreateEventRuleRequest {
  endpoints?: [ 
    {
      endpointType?: string(name='EndpointType', description='This parameter is required.', example='http'),
      endpointValue?: string(name='EndpointValue', description='This parameter is required.', example='test-xxx-queue'),
    }
  ](name='Endpoints', description='This parameter is required.'),
  eventTypes?: [ string ](name='EventTypes', description='This parameter is required.'),
  matchRules?: [[
    EventMatchRule
  ]  ](name='MatchRules', description='This parameter is required.'),
  productName?: string(name='ProductName', description='This parameter is required.', example='oss'),
  ruleName?: string(name='RuleName', description='This parameter is required.', example='rule-xsXDW'),
}

model CreateEventRuleShrinkRequest {
  endpointsShrink?: string(name='Endpoints', description='This parameter is required.'),
  eventTypesShrink?: string(name='EventTypes', description='This parameter is required.'),
  matchRulesShrink?: string(name='MatchRules', description='This parameter is required.'),
  productName?: string(name='ProductName', description='This parameter is required.', example='oss'),
  ruleName?: string(name='RuleName', description='This parameter is required.', example='rule-xsXDW'),
}

model CreateEventRuleResponseBody = {
  code?: long(name='Code', example='200'),
  data?: string(name='Data', example='rule-xsXDW'),
  message?: string(name='Message', example='operation success'),
  requestId?: string(name='RequestId', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', example='Success'),
  success?: boolean(name='Success', example='true'),
}

model CreateEventRuleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateEventRuleResponseBody(name='body'),
}

/**
 * @summary 创建事件规则
 *
 * @param tmpReq CreateEventRuleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateEventRuleResponse
 */
async function createEventRuleWithOptions(tmpReq: CreateEventRuleRequest, runtime: Util.RuntimeOptions): CreateEventRuleResponse {
  Util.validateModel(tmpReq);
  var request = new CreateEventRuleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.endpoints)) {
    request.endpointsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.endpoints, 'Endpoints', 'json');
  }
  if (!Util.isUnset(tmpReq.eventTypes)) {
    request.eventTypesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.eventTypes, 'EventTypes', 'json');
  }
  if (!Util.isUnset(tmpReq.matchRules)) {
    request.matchRulesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.matchRules, 'MatchRules', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.endpointsShrink)) {
    query['Endpoints'] = request.endpointsShrink;
  }
  if (!Util.isUnset(request.eventTypesShrink)) {
    query['EventTypes'] = request.eventTypesShrink;
  }
  if (!Util.isUnset(request.matchRulesShrink)) {
    query['MatchRules'] = request.matchRulesShrink;
  }
  if (!Util.isUnset(request.productName)) {
    query['ProductName'] = request.productName;
  }
  if (!Util.isUnset(request.ruleName)) {
    query['RuleName'] = request.ruleName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateEventRule',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建事件规则
 *
 * @param request CreateEventRuleRequest
 * @return CreateEventRuleResponse
 */
async function createEventRule(request: CreateEventRuleRequest): CreateEventRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return createEventRuleWithOptions(request, runtime);
}

model CreateQueueRequest {
  delaySeconds?: long(name='DelaySeconds', description='The period after which all messages sent to the queue are consumed. Valid values: 0 to 604800. Unit: seconds. Default value: 0', example='0'),
  dlqPolicy?: {
    deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='deadLetterQueue'),
    enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
    maxReceiveCount?: int32(name='MaxReceiveCount', description='The maximum number of retries.', example='3'),
  }(name='DlqPolicy', description='The dead-letter queue policy.'),
  enableLogging?: boolean(name='EnableLogging', description='Specifies whether to enable the log management feature. Valid values:

*   true: enabled.
*   false: disabled.

Default value: false.', example='true'),
  maximumMessageSize?: long(name='MaximumMessageSize', description='The maximum length of the message that is sent to the queue. Valid values: 1024 to 65536. Unit: bytes. Default value: 65536.', example='65536'),
  messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the queue. After the specified retention period ends, the message is deleted regardless of whether the message is consumed. Valid values: 60 to 604800. Unit: seconds. Default value: 345600.', example='345600'),
  pollingWaitSeconds?: long(name='PollingWaitSeconds', description='The maximum duration for which long polling requests are held after the ReceiveMessage operation is called. Valid values: 0 to 30. Unit: seconds. Default value: 0', example='0'),
  queueName?: string(name='QueueName', description='The name of the queue.

This parameter is required.', example='06273500-249F-5863-121D-74D51123****'),
  tag?: [ 
    {
      key?: string(name='Key', description='The key of the tag.', example='tag1'),
      value?: string(name='Value', description='The tag value.', example='test'),
    }
  ](name='Tag', description='The tags.'),
  visibilityTimeout?: long(name='VisibilityTimeout', description='The duration for which a message stays in the Inactive state after the message is received from the queue. Valid values: 1 to 43200. Unit: seconds. Default value: 30.', example='60'),
}

model CreateQueueShrinkRequest {
  delaySeconds?: long(name='DelaySeconds', description='The period after which all messages sent to the queue are consumed. Valid values: 0 to 604800. Unit: seconds. Default value: 0', example='0'),
  dlqPolicyShrink?: string(name='DlqPolicy', description='The dead-letter queue policy.'),
  enableLogging?: boolean(name='EnableLogging', description='Specifies whether to enable the log management feature. Valid values:

*   true: enabled.
*   false: disabled.

Default value: false.', example='true'),
  maximumMessageSize?: long(name='MaximumMessageSize', description='The maximum length of the message that is sent to the queue. Valid values: 1024 to 65536. Unit: bytes. Default value: 65536.', example='65536'),
  messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the queue. After the specified retention period ends, the message is deleted regardless of whether the message is consumed. Valid values: 60 to 604800. Unit: seconds. Default value: 345600.', example='345600'),
  pollingWaitSeconds?: long(name='PollingWaitSeconds', description='The maximum duration for which long polling requests are held after the ReceiveMessage operation is called. Valid values: 0 to 30. Unit: seconds. Default value: 0', example='0'),
  queueName?: string(name='QueueName', description='The name of the queue.

This parameter is required.', example='06273500-249F-5863-121D-74D51123****'),
  tag?: [ 
    {
      key?: string(name='Key', description='The key of the tag.', example='tag1'),
      value?: string(name='Value', description='The tag value.', example='test'),
    }
  ](name='Tag', description='The tags.'),
  visibilityTimeout?: long(name='VisibilityTimeout', description='The duration for which a message stays in the Inactive state after the message is received from the queue. Valid values: 1 to 43200. Unit: seconds. Default value: 30.', example='60'),
}

model CreateQueueResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    code?: long(name='Code', description='The response code.', example='200'),
    message?: string(name='Message', description='The returned message.'),
    success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123E62C'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model CreateQueueResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateQueueResponseBody(name='body'),
}

/**
 * @summary Creates a queue.
 *
 * @param tmpReq CreateQueueRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateQueueResponse
 */
async function createQueueWithOptions(tmpReq: CreateQueueRequest, runtime: Util.RuntimeOptions): CreateQueueResponse {
  Util.validateModel(tmpReq);
  var request = new CreateQueueShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.dlqPolicy)) {
    request.dlqPolicyShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.dlqPolicy, 'DlqPolicy', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.delaySeconds)) {
    query['DelaySeconds'] = request.delaySeconds;
  }
  if (!Util.isUnset(request.dlqPolicyShrink)) {
    query['DlqPolicy'] = request.dlqPolicyShrink;
  }
  if (!Util.isUnset(request.enableLogging)) {
    query['EnableLogging'] = request.enableLogging;
  }
  if (!Util.isUnset(request.maximumMessageSize)) {
    query['MaximumMessageSize'] = request.maximumMessageSize;
  }
  if (!Util.isUnset(request.messageRetentionPeriod)) {
    query['MessageRetentionPeriod'] = request.messageRetentionPeriod;
  }
  if (!Util.isUnset(request.pollingWaitSeconds)) {
    query['PollingWaitSeconds'] = request.pollingWaitSeconds;
  }
  if (!Util.isUnset(request.queueName)) {
    query['QueueName'] = request.queueName;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  if (!Util.isUnset(request.visibilityTimeout)) {
    query['VisibilityTimeout'] = request.visibilityTimeout;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateQueue',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Creates a queue.
 *
 * @param request CreateQueueRequest
 * @return CreateQueueResponse
 */
async function createQueue(request: CreateQueueRequest): CreateQueueResponse {
  var runtime = new Util.RuntimeOptions{};
  return createQueueWithOptions(request, runtime);
}

model CreateTopicRequest {
  enableLogging?: boolean(name='EnableLogging', description='Specifies whether to enable the log management feature. Valid values:

*   true: enabled.
*   false: disabled. Default value: false.', example='true'),
  maxMessageSize?: long(name='MaxMessageSize', description='The maximum length of the message that is sent to the topic. Valid values: 1024 to 65536. Unit: bytes. Default value: 65536.', example='10240'),
  tag?: [ 
    {
      key?: string(name='Key', description='The tag key.', example='tag1'),
      value?: string(name='Value', description='The tag value.', example='joyce.wang'),
    }
  ](name='Tag', description='The tags.'),
  topicName?: string(name='TopicName', description='The name of the topic that you want to create.

This parameter is required.', example='test'),
}

model CreateTopicResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    code?: long(name='Code', description='The response code.', example='200'),
    message?: string(name='Message', description='The returned message.'),
    success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123E62C'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model CreateTopicResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateTopicResponseBody(name='body'),
}

/**
 * @summary Creates a topic.
 *
 * @param request CreateTopicRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateTopicResponse
 */
async function createTopicWithOptions(request: CreateTopicRequest, runtime: Util.RuntimeOptions): CreateTopicResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.enableLogging)) {
    body['EnableLogging'] = request.enableLogging;
  }
  if (!Util.isUnset(request.maxMessageSize)) {
    body['MaxMessageSize'] = request.maxMessageSize;
  }
  if (!Util.isUnset(request.topicName)) {
    body['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateTopic',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Creates a topic.
 *
 * @param request CreateTopicRequest
 * @return CreateTopicResponse
 */
async function createTopic(request: CreateTopicRequest): CreateTopicResponse {
  var runtime = new Util.RuntimeOptions{};
  return createTopicWithOptions(request, runtime);
}

model DeleteEventRuleRequest {
  productName?: string(name='ProductName', description='This parameter is required.', example='oss'),
  ruleName?: string(name='RuleName', description='This parameter is required.', example='rule-xsXDW'),
}

model DeleteEventRuleResponseBody = {
  code?: long(name='Code', example='200'),
  message?: string(name='Message', example='operation success'),
  requestId?: string(name='RequestId', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', example='Success'),
  success?: boolean(name='Success', example='true'),
}

model DeleteEventRuleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteEventRuleResponseBody(name='body'),
}

/**
 * @summary 删除事件规则
 *
 * @param request DeleteEventRuleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteEventRuleResponse
 */
async function deleteEventRuleWithOptions(request: DeleteEventRuleRequest, runtime: Util.RuntimeOptions): DeleteEventRuleResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.productName)) {
    query['ProductName'] = request.productName;
  }
  if (!Util.isUnset(request.ruleName)) {
    query['RuleName'] = request.ruleName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteEventRule',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 删除事件规则
 *
 * @param request DeleteEventRuleRequest
 * @return DeleteEventRuleResponse
 */
async function deleteEventRule(request: DeleteEventRuleRequest): DeleteEventRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteEventRuleWithOptions(request, runtime);
}

model DeleteQueueRequest {
  queueName?: string(name='QueueName', description='The name of the queue.

This parameter is required.', example='tf-testAccMNSQueue-525478433321945943'),
}

model DeleteQueueResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    code?: long(name='Code', description='The response code.', example='200'),
    message?: string(name='Message', description='The returned message.'),
    success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model DeleteQueueResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteQueueResponseBody(name='body'),
}

/**
 * @summary Deletes a queue.
 *
 * @param request DeleteQueueRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteQueueResponse
 */
async function deleteQueueWithOptions(request: DeleteQueueRequest, runtime: Util.RuntimeOptions): DeleteQueueResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.queueName)) {
    query['QueueName'] = request.queueName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteQueue',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Deletes a queue.
 *
 * @param request DeleteQueueRequest
 * @return DeleteQueueResponse
 */
async function deleteQueue(request: DeleteQueueRequest): DeleteQueueResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteQueueWithOptions(request, runtime);
}

model DeleteTopicRequest {
  topicName?: string(name='TopicName', description='The name of the topic that you want to delete.

This parameter is required.', example='tf-testAccMNSTopic-112965059402264645'),
}

model DeleteTopicResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: map[string]any(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model DeleteTopicResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteTopicResponseBody(name='body'),
}

/**
 * @summary Deletes a topic.
 *
 * @param request DeleteTopicRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteTopicResponse
 */
async function deleteTopicWithOptions(request: DeleteTopicRequest, runtime: Util.RuntimeOptions): DeleteTopicResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteTopic',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Deletes a topic.
 *
 * @param request DeleteTopicRequest
 * @return DeleteTopicResponse
 */
async function deleteTopic(request: DeleteTopicRequest): DeleteTopicResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteTopicWithOptions(request, runtime);
}

model DisableEndpointRequest {
  endpointType?: string(name='EndpointType', description='The type of the endpoint. Value:

*   **public**: indicates an public endpoint. (Only the public endpoint is supported.)

This parameter is required.', example='public'),
}

model DisableEndpointResponseBody = {
  code?: long(name='Code', description='The HTTP status code.', example='200'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model DisableEndpointResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DisableEndpointResponseBody(name='body'),
}

/**
 * @summary You can call this operation to disenable the endpoint of a type. After the endpoint is disabled, all requests from the endpoint are blocked and an error is returned.
 *
 * @param request DisableEndpointRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DisableEndpointResponse
 */
async function disableEndpointWithOptions(request: DisableEndpointRequest, runtime: Util.RuntimeOptions): DisableEndpointResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endpointType)) {
    query['EndpointType'] = request.endpointType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DisableEndpoint',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary You can call this operation to disenable the endpoint of a type. After the endpoint is disabled, all requests from the endpoint are blocked and an error is returned.
 *
 * @param request DisableEndpointRequest
 * @return DisableEndpointResponse
 */
async function disableEndpoint(request: DisableEndpointRequest): DisableEndpointResponse {
  var runtime = new Util.RuntimeOptions{};
  return disableEndpointWithOptions(request, runtime);
}

model EnableEndpointRequest {
  endpointType?: string(name='EndpointType', description='The type of the endpoint. Valid value:

*   **public**: indicates public endpoint. (Only the public is supported.)

This parameter is required.', example='public'),
}

model EnableEndpointResponseBody = {
  code?: long(name='Code', description='The HTTP status code.', example='200'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model EnableEndpointResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnableEndpointResponseBody(name='body'),
}

/**
 * @summary You can call this operation to enable the endpoint of a type. If the endpoint is enabled, requests from the endpoint that are included in the access control lists (ACLs) are not blocked.
 *
 * @param request EnableEndpointRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnableEndpointResponse
 */
async function enableEndpointWithOptions(request: EnableEndpointRequest, runtime: Util.RuntimeOptions): EnableEndpointResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endpointType)) {
    query['EndpointType'] = request.endpointType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'EnableEndpoint',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary You can call this operation to enable the endpoint of a type. If the endpoint is enabled, requests from the endpoint that are included in the access control lists (ACLs) are not blocked.
 *
 * @param request EnableEndpointRequest
 * @return EnableEndpointResponse
 */
async function enableEndpoint(request: EnableEndpointRequest): EnableEndpointResponse {
  var runtime = new Util.RuntimeOptions{};
  return enableEndpointWithOptions(request, runtime);
}

model GetEndpointAttributeRequest {
  endpointType?: string(name='EndpointType', description='The type of the endpoint. Value:

*   **public**: indicates public endpoint. (Only the public is supported.)

This parameter is required.', example='public'),
}

model GetEndpointAttributeResponseBody = {
  code?: long(name='Code', description='The HTTP status code.', example='200'),
  data?: {
    cidrList?: [ 
      {
        aclStrategy?: string(name='AclStrategy', description='The ACL policy. Valid values:

*   **allow**: indicates that the current endpoint allows access from the corresponding CIDR block. (Only allow is supported.)', example='allow'),
        cidr?: string(name='Cidr', description='The CIDR block.', example='172.18.0.0/24'),
        createTime?: long(name='CreateTime', description='The creation time.', example='1701951224000'),
      }
    ](name='CidrList', description='The list of CIDR block.'),
    endpointEnabled?: boolean(name='EndpointEnabled', description='Specifies whether the endpoint is enabled.', example='true'),
  }(name='Data', description='The response data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model GetEndpointAttributeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetEndpointAttributeResponseBody(name='body'),
}

/**
 * @summary GetEndpointAttribute
 *
 * @param request GetEndpointAttributeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetEndpointAttributeResponse
 */
async function getEndpointAttributeWithOptions(request: GetEndpointAttributeRequest, runtime: Util.RuntimeOptions): GetEndpointAttributeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endpointType)) {
    query['EndpointType'] = request.endpointType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetEndpointAttribute',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary GetEndpointAttribute
 *
 * @param request GetEndpointAttributeRequest
 * @return GetEndpointAttributeResponse
 */
async function getEndpointAttribute(request: GetEndpointAttributeRequest): GetEndpointAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return getEndpointAttributeWithOptions(request, runtime);
}

model GetQueueAttributesRequest {
  queueName?: string(name='QueueName', description='The name of the queue.

This parameter is required.', example='demo-queue'),
  tag?: [ 
    {
      key?: string(name='Key', description='The tag key.', example='tag1'),
      value?: string(name='Value', description='The tag value.', example='test'),
    }
  ](name='Tag', description='The tags.'),
}

model GetQueueAttributesResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    activeMessages?: long(name='ActiveMessages', description='The total number of messages that are in the Active state in the queue. The value is an approximate value. Default value: 0. We recommend that you do not use the return value and that you call CloudMonitor API operations to query the metric value.', example='20'),
    createTime?: long(name='CreateTime', description='The time when the queue was created.', example='1250700999'),
    delayMessages?: long(name='DelayMessages', description='The total number of messages that are in the Delayed state in the queue. The value is an approximate value. Default value: 0. We recommend that you do not use the return value and that you call CloudMonitor API operations to query the metric value.', example='0'),
    delaySeconds?: long(name='DelaySeconds', description='The period after which all messages sent to the queue are consumed. Unit: seconds.', example='30'),
    dlqPolicy?: {
      deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='deadLetterTargetQueue'),
      enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
      maxReceiveCount?: string(name='MaxReceiveCount', description='The maximum number of retries.', example='3'),
    }(name='DlqPolicy', description='The dead-letter queue policy.'),
    inactiveMessages?: long(name='InactiveMessages', description='The total number of messages that are in the Inactive state in the queue. The value is an approximate value. Default value: 0. We recommend that you do not use the return value and that you call CloudMonitor API operations to query the metric value.', example='0'),
    lastModifyTime?: long(name='LastModifyTime', description='The time when the queue was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1250700999'),
    loggingEnabled?: boolean(name='LoggingEnabled', description='Indicates whether the logging feature is enabled. Valid values:

*   True
*   False', example='True'),
    maximumMessageSize?: long(name='MaximumMessageSize', description='The maximum length of the message that is sent to the queue. Unit: bytes.', example='65536'),
    messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the queue. After the specified retention period ends, the message is deleted regardless of whether the message is received. Unit: seconds.', example='65536'),
    pollingWaitSeconds?: long(name='PollingWaitSeconds', description='The maximum duration for which long polling requests are held after the ReceiveMessage operation is called. Unit: seconds.', example='0'),
    queueName?: string(name='QueueName', description='The name of the queue.', example='demo-queue'),
    tags?: [ 
      {
        tagKey?: string(name='TagKey', description='The tag key.', example='tag1'),
        tagValue?: string(name='TagValue', description='The tag value.', example='test'),
      }
    ](name='Tags', description='The tag.'),
    visibilityTimeout?: long(name='VisibilityTimeout', description='The duration for which a message stays in the Inactive state after the message is received from the queue. Valid values: 1 to 43200. Unit: seconds. Default value: 30.', example='60'),
  }(name='Data', description='The data returned.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model GetQueueAttributesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetQueueAttributesResponseBody(name='body'),
}

/**
 * @summary Queries the attributes of an existing queue.
 *
 * @param request GetQueueAttributesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetQueueAttributesResponse
 */
async function getQueueAttributesWithOptions(request: GetQueueAttributesRequest, runtime: Util.RuntimeOptions): GetQueueAttributesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.queueName)) {
    query['QueueName'] = request.queueName;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetQueueAttributes',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the attributes of an existing queue.
 *
 * @param request GetQueueAttributesRequest
 * @return GetQueueAttributesResponse
 */
async function getQueueAttributes(request: GetQueueAttributesRequest): GetQueueAttributesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getQueueAttributesWithOptions(request, runtime);
}

model GetSubscriptionAttributesRequest {
  subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.

This parameter is required.', example='MySubscription'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='MyTopic'),
}

model GetSubscriptionAttributesResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    createTime?: long(name='CreateTime', description='The time when the subscription was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554806'),
    dlqPolicy?: {
      deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='deadLetterTargetQueue'),
      enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
    }(name='DlqPolicy', description='The dead-letter queue policy.'),
    endpoint?: string(name='Endpoint', description='The endpoint to which the messages are pushed.', example='http://example.com'),
    filterTag?: string(name='FilterTag', description='The tag that is used to filter messages. Only the messages that are attached with the specified tag can be pushed.', example='important'),
    lastModifyTime?: long(name='LastModifyTime', description='The time when the subscription was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554962'),
    notifyContentFormat?: string(name='NotifyContentFormat', description='The content format of the messages that are pushed to the endpoint. Valid values:

*   XML
*   JSON
*   SIMPLIFIED', example='XML'),
    notifyStrategy?: string(name='NotifyStrategy', description='The retry policy that is applied if an error occurs when Message Service (MNS) pushes messages to the endpoint. Valid values:

*   BACKOFF_RETRY
*   EXPONENTIAL_DECAY_RETRY', example='BACKOFF_RETRY'),
    subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.', example='MySubscription'),
    topicName?: string(name='TopicName', description='The name of the topic.', example='MyTopic'),
    topicOwner?: string(name='TopicOwner', description='The Alibaba Cloud account ID of the topic owner.', example='123456789098****'),
  }(name='Data', description='The data returned.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model GetSubscriptionAttributesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetSubscriptionAttributesResponseBody(name='body'),
}

/**
 * @summary Queries the attributes of a subscription.
 *
 * @param request GetSubscriptionAttributesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetSubscriptionAttributesResponse
 */
async function getSubscriptionAttributesWithOptions(request: GetSubscriptionAttributesRequest, runtime: Util.RuntimeOptions): GetSubscriptionAttributesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.subscriptionName)) {
    query['SubscriptionName'] = request.subscriptionName;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetSubscriptionAttributes',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the attributes of a subscription.
 *
 * @param request GetSubscriptionAttributesRequest
 * @return GetSubscriptionAttributesResponse
 */
async function getSubscriptionAttributes(request: GetSubscriptionAttributesRequest): GetSubscriptionAttributesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getSubscriptionAttributesWithOptions(request, runtime);
}

model GetTopicAttributesRequest {
  tag?: [ 
    {
      key?: string(name='Key', description='The tag key.', example='tag1'),
      value?: string(name='Value', description='The tag value.', example='test'),
    }
  ](name='Tag', description='The tag.'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='demo-topic'),
}

model GetTopicAttributesResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    createTime?: long(name='CreateTime', description='The time when the topic was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554277'),
    lastModifyTime?: long(name='LastModifyTime', description='The time when the topic was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554460'),
    loggingEnabled?: boolean(name='LoggingEnabled', description='Indicates whether the logging feature is enabled. Valid values:

*   True
*   False', example='True'),
    maxMessageSize?: long(name='MaxMessageSize', description='The maximum length of the message that is sent to the topic. Unit: bytes.', example='65536'),
    messageCount?: long(name='MessageCount', description='The number of messages in the topic.', example='0'),
    messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the topic. After the specified retention period ends, the message is deleted regardless of whether the message is received. Unit: seconds.', example='86400'),
    tags?: [ 
      {
        tagKey?: string(name='TagKey', description='The tag key.', example='tag1'),
        tagValue?: string(name='TagValue', description='The tag value.', example='test'),
      }
    ](name='Tags', description='The tags added to the resources.'),
    topicName?: string(name='TopicName', description='The name of the topic.', example='demo-topic'),
  }(name='Data', description='The data returned.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model GetTopicAttributesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTopicAttributesResponseBody(name='body'),
}

/**
 * @summary Queries the attributes of a topic.
 *
 * @param request GetTopicAttributesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTopicAttributesResponse
 */
async function getTopicAttributesWithOptions(request: GetTopicAttributesRequest, runtime: Util.RuntimeOptions): GetTopicAttributesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTopicAttributes',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the attributes of a topic.
 *
 * @param request GetTopicAttributesRequest
 * @return GetTopicAttributesResponse
 */
async function getTopicAttributes(request: GetTopicAttributesRequest): GetTopicAttributesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTopicAttributesWithOptions(request, runtime);
}

model ListQueueRequest {
  pageNum?: long(name='PageNum', description='The page number. Valid values: 1 to 100000000. If you set this parameter to a value smaller than 1, the value of this parameter is 1 by default. If you set this parameter to a value greater than 100000000, the value of this parameter is 100000000 by default.', example='1'),
  pageSize?: long(name='PageSize', description='The number of entries per page. Value values: 10 to 50. If you set this parameter to a value smaller than 10, the value of this parameter is 10 by default. If you set this parameter to a value greater than 50, the value of this parameter is 50 by default.', example='20'),
  queueName?: string(name='QueueName', description='The name of the queue.', example='demo-queue'),
  tag?: [ 
    {
      key?: string(name='Key', description='The tag key.', example='tag1'),
      value?: string(name='Value', description='The tag value.', example='test'),
    }
  ](name='Tag', description='The tags.'),
}

model ListQueueResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    pageData?: [ 
      {
        activeMessages?: long(name='ActiveMessages', description='The total number of messages that are in the Active state in the queue. The value is an approximate number. Default value: 0. We recommend that you do not use the return value and that you call CloudMonitor API operations to query the metric value.', example='20'),
        createTime?: long(name='CreateTime', description='The time when the queue was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1250700999'),
        delayMessages?: long(name='DelayMessages', description='The total number of the messages that are in the Delayed state in the queue. The value is an approximate number. Default value: 0. We recommend that you do not use the return value and that you call CloudMonitor API operations to query the metric value.', example='0'),
        delaySeconds?: long(name='DelaySeconds', description='The period after which all messages sent to the queue are consumed. Unit: seconds.', example='30'),
        dlqPolicy?: {
          deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='deadLetterTargetQueue'),
          enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
          maxReceiveCount?: string(name='MaxReceiveCount', description='The maximum number of retries.', example='3'),
        }(name='DlqPolicy', description='The dead-letter queue policy.'),
        inactiveMessages?: long(name='InactiveMessages', description='The total number of the messages that are in the Inactive state in the queue. The value is an approximate number. Default value: 0. We recommend that you do not use the return value and that you call CloudMonitor API operations to query the metric value.', example='0'),
        lastModifyTime?: long(name='LastModifyTime', description='The time when the queue was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1250700999'),
        loggingEnabled?: boolean(name='LoggingEnabled', description='Indicates whether the logging feature is enabled. Valid values:

*   True
*   False', example='True'),
        maximumMessageSize?: long(name='MaximumMessageSize', description='The maximum length of the message that is sent to the queue. Unit: bytes.', example='65536'),
        messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the queue. After the specified retention period ends, the message is deleted regardless of whether the message is received. Unit: seconds.', example='65536'),
        pollingWaitSeconds?: long(name='PollingWaitSeconds', description='The maximum duration for which long polling requests are held after the ReceiveMessage operation is called. Unit: seconds.', example='0'),
        queueName?: string(name='QueueName', description='The name of the queue.', example='demo-queue'),
        tags?: [ 
          {
            tagKey?: string(name='TagKey', description='The tag key.', example='tag1'),
            tagValue?: string(name='TagValue', description='The tag value.', example='test'),
          }
        ](name='Tags', description='The tags added to the resources.'),
        visibilityTimeout?: long(name='VisibilityTimeout', description='The duration for which a message stays in the Inactive state after the message is received from the queue. Valid values: 1 to 43200. Unit: seconds. Default value: 30.', example='60'),
      }
    ](name='PageData', description='The data returned on the current page.'),
    pageNum?: long(name='PageNum', description='The page number.', example='1'),
    pageSize?: long(name='PageSize', description='The number of entries per page.', example='50'),
    pages?: long(name='Pages', description='The total number of pages returned.', example='3'),
    size?: long(name='Size', description='The number of entries on the current page.', example='20'),
    total?: long(name='Total', description='The total number of entries.', example='130'),
  }(name='Data', description='The data returned.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model ListQueueResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListQueueResponseBody(name='body'),
}

/**
 * @summary Queries all queues that belong to an Alibaba Cloud account. The queues are displayed by page.
 *
 * @param request ListQueueRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListQueueResponse
 */
async function listQueueWithOptions(request: ListQueueRequest, runtime: Util.RuntimeOptions): ListQueueResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.pageNum)) {
    query['PageNum'] = request.pageNum;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.queueName)) {
    query['QueueName'] = request.queueName;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListQueue',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries all queues that belong to an Alibaba Cloud account. The queues are displayed by page.
 *
 * @param request ListQueueRequest
 * @return ListQueueResponse
 */
async function listQueue(request: ListQueueRequest): ListQueueResponse {
  var runtime = new Util.RuntimeOptions{};
  return listQueueWithOptions(request, runtime);
}

model ListSubscriptionByTopicRequest {
  endpointType?: string(name='EndpointType'),
  endpointValue?: string(name='EndpointValue'),
  pageNum?: long(name='PageNum', description='The page number. Valid values: 1 to 100000000. If you set this parameter to a value smaller than 1, the value of this parameter is 1 by default. If you set this parameter to a value greater than 100000000, the value of this parameter is 100000000 by default.', example='1'),
  pageSize?: long(name='PageSize', description='The number of entries per page. Value values: 10 to 50. If you set this parameter to a value smaller than 10, the value of this parameter is 10 by default. If you set this parameter to a value greater than 50, the value of this parameter is 50 by default.', example='20'),
  subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.', example='demo-subscription'),
  topicName?: string(name='TopicName', description='The topic name.', example='test'),
}

model ListSubscriptionByTopicResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    pageData?: [ 
      {
        createTime?: long(name='CreateTime', description='The time when the subscription was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554806'),
        dlqPolicy?: {
          deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='dead-letter-queue'),
          enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
        }(name='DlqPolicy', description='The dead-letter queue policy.'),
        endpoint?: string(name='Endpoint', description='The endpoint to which the messages are pushed.', example='http://example.com'),
        filterTag?: string(name='FilterTag', description='The tag that is used to filter messages. Only the messages that are attached with the specified tag can be pushed.', example='important'),
        lastModifyTime?: long(name='LastModifyTime', description='The time when the subscription was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554806'),
        notifyContentFormat?: string(name='NotifyContentFormat', description='The content format of the messages that are pushed to the endpoint. Valid values:

*   XML
*   JSON
*   SIMPLIFIED', example='XML'),
        notifyStrategy?: string(name='NotifyStrategy', description='The retry policy that is applied if an error occurs when Message Service (MNS) pushes messages to the endpoint. Valid values:

*   BACKOFF_RETRY
*   EXPONENTIAL_DECAY_RETRY', example='BACKOFF_RETRY'),
        subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.', example='MySubscription'),
        topicName?: string(name='TopicName', description='The name of the topic.', example='MyTopic'),
        topicOwner?: string(name='TopicOwner', description='The Alibaba Cloud account ID of the topic owner.', example='123456789098****'),
      }
    ](name='PageData', description='The data returned on the current page.'),
    pageNum?: long(name='PageNum', description='The page number.', example='1'),
    pageSize?: long(name='PageSize', description='The number of entries per page.', example='50'),
    pages?: long(name='Pages', description='The total number of pages returned.', example='3'),
    size?: long(name='Size', description='The number of entries on the current page.', example='20'),
    total?: long(name='Total', description='The total number of entries returned.', example='130'),
  }(name='Data', description='The data returned.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model ListSubscriptionByTopicResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListSubscriptionByTopicResponseBody(name='body'),
}

/**
 * @summary Queries all subscriptions to a topic. The subscriptions are displayed by page.
 *
 * @param request ListSubscriptionByTopicRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListSubscriptionByTopicResponse
 */
async function listSubscriptionByTopicWithOptions(request: ListSubscriptionByTopicRequest, runtime: Util.RuntimeOptions): ListSubscriptionByTopicResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endpointType)) {
    query['EndpointType'] = request.endpointType;
  }
  if (!Util.isUnset(request.endpointValue)) {
    query['EndpointValue'] = request.endpointValue;
  }
  if (!Util.isUnset(request.pageNum)) {
    query['PageNum'] = request.pageNum;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.subscriptionName)) {
    query['SubscriptionName'] = request.subscriptionName;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSubscriptionByTopic',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries all subscriptions to a topic. The subscriptions are displayed by page.
 *
 * @param request ListSubscriptionByTopicRequest
 * @return ListSubscriptionByTopicResponse
 */
async function listSubscriptionByTopic(request: ListSubscriptionByTopicRequest): ListSubscriptionByTopicResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSubscriptionByTopicWithOptions(request, runtime);
}

model ListTopicRequest {
  pageNum?: long(name='PageNum', description='The page number. Valid values: 1 to 100000000. If you set this parameter to a value smaller than 1, the value of this parameter is 1 by default. If you set this parameter to a value greater than 100000000, the value of this parameter is 100000000 by default.', example='1'),
  pageSize?: long(name='PageSize', description='The number of entries per page. Value values: 10 to 50. If you set this parameter to a value smaller than 10, the value of this parameter is 10 by default. If you set this parameter to a value greater than 50, the value of this parameter is 50 by default.', example='20'),
  tag?: [ 
    {
      key?: string(name='Key', description='The tag key.', example='tag1'),
      value?: string(name='Value', description='The tag value.', example='test'),
    }
  ](name='Tag', description='The tags.'),
  topicName?: string(name='TopicName', description='The name of the topic.', example='test'),
}

model ListTopicResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    pageData?: [ 
      {
        createTime?: long(name='CreateTime', description='The time when the subscription was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554962'),
        lastModifyTime?: long(name='LastModifyTime', description='The time when the subscription was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.', example='1449554962'),
        loggingEnabled?: boolean(name='LoggingEnabled', description='Indicates whether the logging feature is enabled.

*   True
*   False', example='True'),
        maxMessageSize?: long(name='MaxMessageSize', description='The maximum length of the message that is sent to the topic. Unit: bytes.', example='65536'),
        messageCount?: long(name='MessageCount', description='The number of messages in the topic.', example='0'),
        messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the topic. After the specified retention period ends, the message is deleted regardless of whether the message is received. Unit: seconds.', example='86400'),
        tags?: [ 
          {
            tagKey?: string(name='TagKey', description='The tag key.', example='tag1'),
            tagValue?: string(name='TagValue', description='The tag value.', example='test'),
          }
        ](name='Tags', description='The tags added to the resources.'),
        topicInnerUrl?: string(name='TopicInnerUrl', description='The internal URL of the message topic. The internal URL can be accessed over an internal network.', example='http:// 111111111****.mns.us-west-1-internal.aliyuncs.com/topics/testTopic'),
        topicName?: string(name='TopicName', description='The name of the topic.', example='demo-topic'),
        topicUrl?: string(name='TopicUrl', description='The URL of the message topic.', example='http:// 111111111****.mns.us-west-1.aliyuncs.com/topics/testTopic'),
      }
    ](name='PageData', description='The data returned on the current page.'),
    pageNum?: long(name='PageNum', description='The page number.', example='1'),
    pageSize?: long(name='PageSize', description='The number of entries per page.', example='50'),
    total?: long(name='Total', description='The total number of entries returned.', example='130'),
  }(name='Data', description='The data returned.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model ListTopicResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTopicResponseBody(name='body'),
}

/**
 * @summary Queries the topics that belong to an Alibaba Cloud account. The topics are displayed by page.
 *
 * @param request ListTopicRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTopicResponse
 */
async function listTopicWithOptions(request: ListTopicRequest, runtime: Util.RuntimeOptions): ListTopicResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.pageNum)) {
    query['PageNum'] = request.pageNum;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTopic',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Queries the topics that belong to an Alibaba Cloud account. The topics are displayed by page.
 *
 * @param request ListTopicRequest
 * @return ListTopicResponse
 */
async function listTopic(request: ListTopicRequest): ListTopicResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTopicWithOptions(request, runtime);
}

model RevokeEndpointAclRequest {
  aclStrategy?: string(name='AclStrategy', description='The ACL policy. Value:

*   **allow**: indicates that this operation is included in the Cidr whitelist. (Only the allow is supported.)

This parameter is required.', example='allow'),
  cidrList?: [ string ](name='CidrList', description='The list of CIDR block.

This parameter is required.'),
  endpointType?: string(name='EndpointType', description='The type of the endpoint. Valid values:

*   **public**: indicates public endpoint. (Only the public is supported.)

This parameter is required.', example='public'),
}

model RevokeEndpointAclShrinkRequest {
  aclStrategy?: string(name='AclStrategy', description='The ACL policy. Value:

*   **allow**: indicates that this operation is included in the Cidr whitelist. (Only the allow is supported.)

This parameter is required.', example='allow'),
  cidrListShrink?: string(name='CidrList', description='The list of CIDR block.

This parameter is required.'),
  endpointType?: string(name='EndpointType', description='The type of the endpoint. Valid values:

*   **public**: indicates public endpoint. (Only the public is supported.)

This parameter is required.', example='public'),
}

model RevokeEndpointAclResponseBody = {
  code?: long(name='Code', description='The HTTP status code.', example='200'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model RevokeEndpointAclResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RevokeEndpointAclResponseBody(name='body'),
}

/**
 * @summary You can call this operation to delete one or more rules of access control lists (ACLs) for the endpoint of a type.
 *
 * @param tmpReq RevokeEndpointAclRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return RevokeEndpointAclResponse
 */
async function revokeEndpointAclWithOptions(tmpReq: RevokeEndpointAclRequest, runtime: Util.RuntimeOptions): RevokeEndpointAclResponse {
  Util.validateModel(tmpReq);
  var request = new RevokeEndpointAclShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.cidrList)) {
    request.cidrListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.cidrList, 'CidrList', 'simple');
  }
  var query = {};
  if (!Util.isUnset(request.aclStrategy)) {
    query['AclStrategy'] = request.aclStrategy;
  }
  if (!Util.isUnset(request.cidrListShrink)) {
    query['CidrList'] = request.cidrListShrink;
  }
  if (!Util.isUnset(request.endpointType)) {
    query['EndpointType'] = request.endpointType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RevokeEndpointAcl',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary You can call this operation to delete one or more rules of access control lists (ACLs) for the endpoint of a type.
 *
 * @param request RevokeEndpointAclRequest
 * @return RevokeEndpointAclResponse
 */
async function revokeEndpointAcl(request: RevokeEndpointAclRequest): RevokeEndpointAclResponse {
  var runtime = new Util.RuntimeOptions{};
  return revokeEndpointAclWithOptions(request, runtime);
}

model SetQueueAttributesRequest {
  delaySeconds?: long(name='DelaySeconds', description='The period after which all messages sent to the queue are consumed. Valid values: 0 to 604800. Unit: seconds. Default value: 0', example='0'),
  dlqPolicy?: {
    deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='deadLetterTargetQueue'),
    enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
    maxReceiveCount?: int32(name='MaxReceiveCount', description='The maximum number of retries.', example='3'),
  }(name='DlqPolicy', description='The dead-letter queue policy.'),
  enableLogging?: boolean(name='EnableLogging', description='Specifies whether to enable the log management feature. Valid values:

*   true: enabled.
*   false: disabled. Default value: false.', example='True'),
  maximumMessageSize?: long(name='MaximumMessageSize', description='The maximum length of the message that is sent to the queue. Valid values: 1024 to 65536. Unit: bytes. Default value: 65536.', example='1024'),
  messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the queue. After the specified retention period ends, the message is deleted regardless of whether the message is received. Valid values: 60 to 604800. Unit: seconds. Default value: 345600.', example='120'),
  pollingWaitSeconds?: long(name='PollingWaitSeconds', description='The maximum duration for which long polling requests are held after the ReceiveMessage operation is called. Valid values: 0 to 30. Unit: seconds. Default value: 0', example='0'),
  queueName?: string(name='QueueName', description='The name of the queue.

This parameter is required.', example='testqueue'),
  visibilityTimeout?: long(name='VisibilityTimeout', description='The duration for which a message stays in the Inactive state after the message is received from the queue. Valid values: 1 to 43200. Unit: seconds. Default value: 30.', example='60'),
}

model SetQueueAttributesShrinkRequest {
  delaySeconds?: long(name='DelaySeconds', description='The period after which all messages sent to the queue are consumed. Valid values: 0 to 604800. Unit: seconds. Default value: 0', example='0'),
  dlqPolicyShrink?: string(name='DlqPolicy', description='The dead-letter queue policy.'),
  enableLogging?: boolean(name='EnableLogging', description='Specifies whether to enable the log management feature. Valid values:

*   true: enabled.
*   false: disabled. Default value: false.', example='True'),
  maximumMessageSize?: long(name='MaximumMessageSize', description='The maximum length of the message that is sent to the queue. Valid values: 1024 to 65536. Unit: bytes. Default value: 65536.', example='1024'),
  messageRetentionPeriod?: long(name='MessageRetentionPeriod', description='The maximum duration for which a message is retained in the queue. After the specified retention period ends, the message is deleted regardless of whether the message is received. Valid values: 60 to 604800. Unit: seconds. Default value: 345600.', example='120'),
  pollingWaitSeconds?: long(name='PollingWaitSeconds', description='The maximum duration for which long polling requests are held after the ReceiveMessage operation is called. Valid values: 0 to 30. Unit: seconds. Default value: 0', example='0'),
  queueName?: string(name='QueueName', description='The name of the queue.

This parameter is required.', example='testqueue'),
  visibilityTimeout?: long(name='VisibilityTimeout', description='The duration for which a message stays in the Inactive state after the message is received from the queue. Valid values: 1 to 43200. Unit: seconds. Default value: 30.', example='60'),
}

model SetQueueAttributesResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    code?: long(name='Code', description='The response code.', example='200'),
    message?: string(name='Message', description='The returned message.'),
    success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model SetQueueAttributesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SetQueueAttributesResponseBody(name='body'),
}

/**
 * @summary Modifies a queue.
 *
 * @param tmpReq SetQueueAttributesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SetQueueAttributesResponse
 */
async function setQueueAttributesWithOptions(tmpReq: SetQueueAttributesRequest, runtime: Util.RuntimeOptions): SetQueueAttributesResponse {
  Util.validateModel(tmpReq);
  var request = new SetQueueAttributesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.dlqPolicy)) {
    request.dlqPolicyShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.dlqPolicy, 'DlqPolicy', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.delaySeconds)) {
    query['DelaySeconds'] = request.delaySeconds;
  }
  if (!Util.isUnset(request.dlqPolicyShrink)) {
    query['DlqPolicy'] = request.dlqPolicyShrink;
  }
  if (!Util.isUnset(request.enableLogging)) {
    query['EnableLogging'] = request.enableLogging;
  }
  if (!Util.isUnset(request.maximumMessageSize)) {
    query['MaximumMessageSize'] = request.maximumMessageSize;
  }
  if (!Util.isUnset(request.messageRetentionPeriod)) {
    query['MessageRetentionPeriod'] = request.messageRetentionPeriod;
  }
  if (!Util.isUnset(request.pollingWaitSeconds)) {
    query['PollingWaitSeconds'] = request.pollingWaitSeconds;
  }
  if (!Util.isUnset(request.queueName)) {
    query['QueueName'] = request.queueName;
  }
  if (!Util.isUnset(request.visibilityTimeout)) {
    query['VisibilityTimeout'] = request.visibilityTimeout;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SetQueueAttributes',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Modifies a queue.
 *
 * @param request SetQueueAttributesRequest
 * @return SetQueueAttributesResponse
 */
async function setQueueAttributes(request: SetQueueAttributesRequest): SetQueueAttributesResponse {
  var runtime = new Util.RuntimeOptions{};
  return setQueueAttributesWithOptions(request, runtime);
}

model SetSubscriptionAttributesRequest {
  dlqPolicy?: {
    deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='deadLetterTargetQueue'),
    enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
  }(name='DlqPolicy', description='The dead-letter queue policy.'),
  notifyStrategy?: string(name='NotifyStrategy', description='The retry policy that is applied if an error occurs when Message Service (MNS) pushes messages to the endpoint. Valid values:

*   BACKOFF_RETRY
*   EXPONENTIAL_DECAY_RETRY', example='BACKOFF_RETRY'),
  subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.

This parameter is required.', example='MySubscription'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='test'),
}

model SetSubscriptionAttributesShrinkRequest {
  dlqPolicyShrink?: string(name='DlqPolicy', description='The dead-letter queue policy.'),
  notifyStrategy?: string(name='NotifyStrategy', description='The retry policy that is applied if an error occurs when Message Service (MNS) pushes messages to the endpoint. Valid values:

*   BACKOFF_RETRY
*   EXPONENTIAL_DECAY_RETRY', example='BACKOFF_RETRY'),
  subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.

This parameter is required.', example='MySubscription'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='test'),
}

model SetSubscriptionAttributesResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    code?: long(name='Code', description='The response code.', example='200'),
    message?: string(name='Message', description='The returned message.'),
    success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model SetSubscriptionAttributesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SetSubscriptionAttributesResponseBody(name='body'),
}

/**
 * @summary Modifies the attributes of a subscription.
 *
 * @param tmpReq SetSubscriptionAttributesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SetSubscriptionAttributesResponse
 */
async function setSubscriptionAttributesWithOptions(tmpReq: SetSubscriptionAttributesRequest, runtime: Util.RuntimeOptions): SetSubscriptionAttributesResponse {
  Util.validateModel(tmpReq);
  var request = new SetSubscriptionAttributesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.dlqPolicy)) {
    request.dlqPolicyShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.dlqPolicy, 'DlqPolicy', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.dlqPolicyShrink)) {
    query['DlqPolicy'] = request.dlqPolicyShrink;
  }
  if (!Util.isUnset(request.notifyStrategy)) {
    query['NotifyStrategy'] = request.notifyStrategy;
  }
  if (!Util.isUnset(request.subscriptionName)) {
    query['SubscriptionName'] = request.subscriptionName;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SetSubscriptionAttributes',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Modifies the attributes of a subscription.
 *
 * @param request SetSubscriptionAttributesRequest
 * @return SetSubscriptionAttributesResponse
 */
async function setSubscriptionAttributes(request: SetSubscriptionAttributesRequest): SetSubscriptionAttributesResponse {
  var runtime = new Util.RuntimeOptions{};
  return setSubscriptionAttributesWithOptions(request, runtime);
}

model SetTopicAttributesRequest {
  enableLogging?: boolean(name='EnableLogging', description='Specifies whether to enable the log management feature. Valid values:

*   true: enabled.
*   false: disabled. Default value: false.', example='True'),
  maxMessageSize?: long(name='MaxMessageSize', description='The maximum length of the message that is sent to the topic. Valid values: 1024 to 65536. Unit: bytes. Default value: 65536.', example='65536'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='test'),
}

model SetTopicAttributesResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    code?: long(name='Code', description='The response code.', example='200'),
    message?: string(name='Message', description='The returned message.'),
    success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model SetTopicAttributesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SetTopicAttributesResponseBody(name='body'),
}

/**
 * @summary Modifies the attributes of a topic.
 *
 * @param request SetTopicAttributesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SetTopicAttributesResponse
 */
async function setTopicAttributesWithOptions(request: SetTopicAttributesRequest, runtime: Util.RuntimeOptions): SetTopicAttributesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.enableLogging)) {
    query['EnableLogging'] = request.enableLogging;
  }
  if (!Util.isUnset(request.maxMessageSize)) {
    query['MaxMessageSize'] = request.maxMessageSize;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SetTopicAttributes',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Modifies the attributes of a topic.
 *
 * @param request SetTopicAttributesRequest
 * @return SetTopicAttributesResponse
 */
async function setTopicAttributes(request: SetTopicAttributesRequest): SetTopicAttributesResponse {
  var runtime = new Util.RuntimeOptions{};
  return setTopicAttributesWithOptions(request, runtime);
}

model SubscribeRequest {
  dlqPolicy?: {
    deadLetterTargetQueue?: string(name='DeadLetterTargetQueue', description='The queue to which dead-letter messages are delivered.', example='deadLetterTargetQueue'),
    enabled?: boolean(name='Enabled', description='Specifies whether to enable the dead-letter message delivery.', example='true'),
  }(name='DlqPolicy', description='The dead-letter queue policy.'),
  endpoint?: string(name='Endpoint', description='The receiver endpoint. The format of the endpoint varies based on the terminal type.

*   If you set PushType to http, set Endpoint to an `HTTP URL that starts with http:// or https://`.
*   If you set PushType to queue, set Endpoint to a `queue name`.
*   If you set PushType to mpush, set Endpoint to an `AppKey`.
*   If you set PushType to alisms, set Endpoint to a `mobile number`.
*   If you set PushType to email, set Endpoint to an `email address`.

This parameter is required.', example='http://example.com'),
  messageTag?: string(name='MessageTag', description='The tag that is used to filter messages. Only messages that have the same tag can be pushed. Set the value to a string of no more than 16 characters.

By default, no tag is specified to filter messages.', example='important'),
  notifyContentFormat?: string(name='NotifyContentFormat', description='The content format of the messages that are pushed to the endpoint. Valid values:

*   XML
*   JSON
*   SIMPLIFIED', example='XML'),
  notifyStrategy?: string(name='NotifyStrategy', description='The retry policy that is applied if an error occurs when Message Service (MNS) pushes messages to the endpoint. Valid values:

*   BACKOFF_RETRY
*   EXPONENTIAL_DECAY_RETRY', example='BACKOFF_RETRY'),
  pushType?: string(name='PushType', description='The terminal type. Valid values:

*   http: HTTP services
*   queue: queues
*   mpush: mobile devices
*   alisms: Alibaba Cloud Short Message Service (SMS)
*   email: emails

This parameter is required.', example='queue'),
  subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.

This parameter is required.', example='testSubscription'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='test'),
}

model SubscribeShrinkRequest {
  dlqPolicyShrink?: string(name='DlqPolicy', description='The dead-letter queue policy.'),
  endpoint?: string(name='Endpoint', description='The receiver endpoint. The format of the endpoint varies based on the terminal type.

*   If you set PushType to http, set Endpoint to an `HTTP URL that starts with http:// or https://`.
*   If you set PushType to queue, set Endpoint to a `queue name`.
*   If you set PushType to mpush, set Endpoint to an `AppKey`.
*   If you set PushType to alisms, set Endpoint to a `mobile number`.
*   If you set PushType to email, set Endpoint to an `email address`.

This parameter is required.', example='http://example.com'),
  messageTag?: string(name='MessageTag', description='The tag that is used to filter messages. Only messages that have the same tag can be pushed. Set the value to a string of no more than 16 characters.

By default, no tag is specified to filter messages.', example='important'),
  notifyContentFormat?: string(name='NotifyContentFormat', description='The content format of the messages that are pushed to the endpoint. Valid values:

*   XML
*   JSON
*   SIMPLIFIED', example='XML'),
  notifyStrategy?: string(name='NotifyStrategy', description='The retry policy that is applied if an error occurs when Message Service (MNS) pushes messages to the endpoint. Valid values:

*   BACKOFF_RETRY
*   EXPONENTIAL_DECAY_RETRY', example='BACKOFF_RETRY'),
  pushType?: string(name='PushType', description='The terminal type. Valid values:

*   http: HTTP services
*   queue: queues
*   mpush: mobile devices
*   alisms: Alibaba Cloud Short Message Service (SMS)
*   email: emails

This parameter is required.', example='queue'),
  subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.

This parameter is required.', example='testSubscription'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='test'),
}

model SubscribeResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: string(name='Data', description='The returned data.', example='{\\\\"Code\\\\": 200, \\\\"Success\\\\": True}'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model SubscribeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SubscribeResponseBody(name='body'),
}

/**
 * @summary Creates a subscription to a topic.
 *
 * @param tmpReq SubscribeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SubscribeResponse
 */
async function subscribeWithOptions(tmpReq: SubscribeRequest, runtime: Util.RuntimeOptions): SubscribeResponse {
  Util.validateModel(tmpReq);
  var request = new SubscribeShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.dlqPolicy)) {
    request.dlqPolicyShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.dlqPolicy, 'DlqPolicy', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.dlqPolicyShrink)) {
    query['DlqPolicy'] = request.dlqPolicyShrink;
  }
  if (!Util.isUnset(request.endpoint)) {
    query['Endpoint'] = request.endpoint;
  }
  if (!Util.isUnset(request.messageTag)) {
    query['MessageTag'] = request.messageTag;
  }
  if (!Util.isUnset(request.notifyContentFormat)) {
    query['NotifyContentFormat'] = request.notifyContentFormat;
  }
  if (!Util.isUnset(request.notifyStrategy)) {
    query['NotifyStrategy'] = request.notifyStrategy;
  }
  if (!Util.isUnset(request.pushType)) {
    query['PushType'] = request.pushType;
  }
  if (!Util.isUnset(request.subscriptionName)) {
    query['SubscriptionName'] = request.subscriptionName;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'Subscribe',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Creates a subscription to a topic.
 *
 * @param request SubscribeRequest
 * @return SubscribeResponse
 */
async function subscribe(request: SubscribeRequest): SubscribeResponse {
  var runtime = new Util.RuntimeOptions{};
  return subscribeWithOptions(request, runtime);
}

model UnsubscribeRequest {
  subscriptionName?: string(name='SubscriptionName', description='The name of the subscription.

This parameter is required.', example='MySubscription'),
  topicName?: string(name='TopicName', description='The name of the topic.

This parameter is required.', example='test'),
}

model UnsubscribeResponseBody = {
  code?: long(name='Code', description='The response code.', example='200'),
  data?: {
    code?: long(name='Code', description='The response code.', example='200'),
    message?: string(name='Message', description='The returned message.'),
    success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The returned message.', example='operation success'),
  requestId?: string(name='RequestId', description='The request ID.', example='06273500-249F-5863-121D-74D51123****'),
  status?: string(name='Status', description='The response status.', example='Success'),
  success?: boolean(name='Success', description='Indicates whether the request was successful.', example='true'),
}

model UnsubscribeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UnsubscribeResponseBody(name='body'),
}

/**
 * @summary Deletes a subscription.
 *
 * @param request UnsubscribeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UnsubscribeResponse
 */
async function unsubscribeWithOptions(request: UnsubscribeRequest, runtime: Util.RuntimeOptions): UnsubscribeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.subscriptionName)) {
    query['SubscriptionName'] = request.subscriptionName;
  }
  if (!Util.isUnset(request.topicName)) {
    query['TopicName'] = request.topicName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'Unsubscribe',
    version = '2022-01-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Deletes a subscription.
 *
 * @param request UnsubscribeRequest
 * @return UnsubscribeResponse
 */
async function unsubscribe(request: UnsubscribeRequest): UnsubscribeResponse {
  var runtime = new Util.RuntimeOptions{};
  return unsubscribeWithOptions(request, runtime);
}

